
% martingala.m by SmartBet, Granada, 28-11-11

% Given an integers n, compute the nth Martingale number.

function mar = martingala(n)

% Make sure input is an integer.
if ( n ~= floor(n) )
    error('Argument must be an integer.');
    return;
end

if ~isreal(n)
    error('Argument must be an integer.');
    return;
end

if size(n,1) ~= 1 || size(n,2) ~= 1
    error('Argument must be an integer.');
    return;
end

if ( n <= 0 )
    mar = 0;
    return;
end

mar = 2^(n-1);

